#!/usr/bin/env dash
# network
# todo: have this use network manager? show wifi better? ehh.

`ip link | sed -n 's/^[0-9]: \(.*\):.*$/\1/p'` | read lo int1 int2
if iwconfig $int1 >/dev/null 2>&1; then
	wifi=$int1
	eth0=$int2
else
	wifi=$int2
	eth0=$int1
fi
ip link show $eth0 | grep 'state UP' >/dev/null && int=$eth0 ||int=$wifi
echo -n "${AC}termite -e 'nmtui'${AB}$(icon f0ac)${AE}"
echo -n $int
ping -W 1 -c 1 8.8.8.8 > /dev/null 2>&1 &&
echo -n 'up' || echo -n 'down'
